package com.gourd.common.rbac.service;

import com.alicp.jetcache.anno.CacheType;
import com.alicp.jetcache.anno.Cached;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.IService;
import com.gourd.common.rbac.dto.RbacUserDTO;
import com.gourd.common.rbac.dto.RbacUserSearchDTO;
import com.gourd.common.rbac.entity.RbacUser;
import com.gourd.common.rbac.vo.JwtUser;
import org.springframework.data.domain.PageRequest;

import java.util.List;

/**
 * 用户
 *
 * @author gourd
 * @date 2019-04-02 17:26:16
 * Created by CodeGen .
 */
public interface RbacUserService extends IService<RbacUser> {
    /**
     * 根据账号获取用户信息
     * @param account
     * @return
     */
    @Cached(name = "userService.getByAccount",key="#account", cacheType = CacheType.BOTH)
    RbacUser getByAccount(String account);
    /**
     * 获取所有用户信息
     * @return
     */
    @Cached(name = "userService.findAll",cacheType = CacheType.BOTH)
    List<RbacUser> findAll();

    /**
     * 根据条件获取用户
     * @return
     */
    @Cached(name = "userService.find",cacheType = CacheType.BOTH)
    Page<RbacUser> find(RbacUserSearchDTO rbacUserDTO, PageRequest pageRequest);
    /**
     * 保存用户
     * @return
     */
    RbacUser register(RbacUserDTO user);

    /**
     * 删除用户
     * @return
     */
    void delete(Long userId);

    /**
     * 根据id获取用户信息
     * @param userId
     * @return
     */
    @Cached(name = "userService.getById",key="#userId",cacheType = CacheType.BOTH)
    RbacUser getById(Long userId);

    /**
     * 获取当前用户信息
     * @return
     */
    JwtUser getCurrent();
}